<% @page_title = "Template Details" %>

<%= link_to("<< Back to List", {:action => 'list'}, :class => 'back-link') %>

<div class="template show">
  <h2>Template Details</h2>
  <%= image_tag('template.png', :size => '35x35') %>

  <table class="table" summary="template detail view">
    <tr>
      <th>ID</th>
      <td><%= @template.id %></td>
    </tr>
    <tr>
      <th>Name</th>
      <td><%= @template.name %></td>
    </tr>
    <tr>
      <th>Description</th>
      <td><%= @template.description %></td>
    </tr>
    <tr>
      <th>Notes</th>
      <td><%= @template.notes %></td>
    </tr>
    <tr>
      <th>Created</th>
      <td><%= @template.created_at %></td>
    </tr>
    <tr>
      <th>Updated</th>
      <td><%= @template.updated_at %></td>
    </tr>
    <tr>
      <th>Website Files</th>
      <td>
        <% @template.website_files.each do |www| %>
            <p>
              <%= link_to www[:file], www.file.url %>
              <% if www.function == 'website-index' %>
                <small>*</small>
              <% end %>
            </p>
        <% end %>
      <p><small>* - Index file</small></p>
      </td>
    </tr>
    <tr>
      <th>Email Files</th>
      <td>
        <% @template.email_files.each do |email| %>
            <p>
              <%= link_to email[:file], email.file.url %>
            </p>
        <% end %>
      </td>
    </tr>
    <tr>
      <th>Preview</th>
      <td>
        <% if @images.any? %>
            <% @images.each do |image| %>
                <%= image[:file] %>
                <br/>
                <%= link_to(image_tag(image.file.url), image.file.url) %>
                <br/><br/>
            <% end %>
        <% else %>
            No preview images<br/>
            Add images to <%= @template.location %>
        <% end %>
      </td>
    </tr>
  </table>

</div>
